Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Nov 21, 2024

Currently, the post.can_translate attribute is determined in the post serializer itself, by checking if the detected_language of the post is translatable by the selected translator (e.g. Google, Microsoft)

post.can_translate determines if the translate globe is visible on a post.
Screenshot 2024-11-22 at 1 20 49 AM

This PR moves the check into the translator itself using the language_supported? method, and the translator can determine if a language is translatable rather than doing the check outside the translator. This is needed because Discourse AI does not have the limitation of translatable languages, and the return result of language_supported? will always be true, putting the check inside the post serializer has limitations since all translators will be required to define a SUPPORTED_LANG_MAPPING when there doesn't need to be one always.

@nattsw nattsw force-pushed the translator-supported-lang branch 2 times, most recently from b58be2a to cab0ae0 Compare November 22, 2024 01:28
@nattsw nattsw changed the title DEV: Move logic for language support into translators DEV: Move logic for language support from post serializer into translators Nov 22, 2024
@nattsw nattsw force-pushed the translator-supported-lang branch from cab0ae0 to 3d12bad Compare November 22, 2024 02:03
Copy link
Contributor

@jjaffeux jjaffeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@nattsw
Copy link
Contributor Author

nattsw commented Nov 22, 2024

Thank you @jjaffeux

@nattsw nattsw merged commit 08c8adb into main Nov 22, 2024
3 checks passed
@nattsw nattsw deleted the translator-supported-lang branch November 22, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants